<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      * {
        margin: 0;
        padding: 0;
      }
      a {
        text-decoration: none;
        color: #fff;
      }
      html,
      body {
        width: 100%;
        height: 100%;
        background-color: rgba(0, 0, 0, 0.3);
      }
      .bj {
        width: 640px;
        height: 80%;
        position: absolute;
        overflow: hidden;
        top: 10px;
        bottom: 0;
        left: 0;
        right: 0;
        margin: auto;
        padding: 50px 0;
      }
      .bj img {
        position: absolute;
        top: 0;
        left: 0;
      }
      .bj div {
        height: 65%;
        width: 100%;
        opacity: 0.7;
        overflow: hidden;
        margin-top: 160px;
      }

      audio {
        opacity: 0.3;
        width: 400px;
        position: absolute;
        top: 90%;
        left: 50%;
        margin-left: -200px;
        z-index: 6;
      }

      .move {
        /* opacity: 0.7; */
        width: 150px;
        height: 150px;
        padding: 10px;
        border-radius: 50%;
        border: 15px solid black;
        background-color: #fff;
        animation: move infinite linear 30s;
        position: absolute;
        top: -60%;
        bottom: 0;
        left: 0;
        right: 0;

        z-index: 2;
        margin: auto;
      }
      .imgclick:hover {
        cursor: pointer;
      }
      p {
        width: 400px;
        text-align: center;
        font: 25px/40px "";
        font-weight: bolder;
        color: #fff;
        margin: 220px auto;
        overflow: hidden;
      }
      h1 {
        height: 855px;
        position: absolute;
        top: 0;
      }
      @keyframes move {
        0% {
          transform: rotate(0deg);
        }
        100% {
          transform: rotate(360deg);
        }
      }
    </style>
  </head>
  <body>
    <a href="javascript:void(0);" onclick="getCurrentTime('firefox');"
      >获取播放时间</a
    ><br />
    <a href="javascript:void(0);" onclick="change();">30秒开始播放</a><br />
    <a href="javascript:void(0);" onclick="playOrPaused('firefox',this);"
      >播放</a
    ><br />
    <a href="javascript:void(0);" onclick="hideOrShowControls('firefox',this);"
      >隐藏控制框</a
    ><br />
    <a href="javascript:void(0);" onclick="muted('firefox',this);">开启静音</a>
    <br />
    <input
      type="button"
      value="+"
      id="upVol"
      onclick="vol('firefox' , 'up' , this )"
    />音量<input
      type="button"
      value="-"
      onclick="vol('firefox' , 'down' ,this )"
    />
    <img
      src="./xusong.jpg"
      alt=""
      class="imgclick move"
      id="stop1"
      onclick="run()"
    />
    <div class="bj">
      <img src="./bg.webp" width="100%" />
      <div>
        <p>
          清明雨上——许嵩<br />
          作词：许嵩 <br />
          作曲：许嵩<br />
          窗透初晓 日照西桥 云自摇<br />
          想你当年荷风微摆的衣角<br />
          木雕流金 岁月涟漪 七年前封笔<br />
          因为我今生挥毫只为你<br />
          雨打湿了眼眶 年年倚井盼归堂<br />
          最怕不觉泪已拆两行<br />
          我在人间彷徨 寻不到你的天堂<br />
          东瓶西镜放 恨不能遗忘<br />
          又是清明雨上 折菊寄到你身旁<br />
          把你最爱的歌来轻轻唱<br />
          ______________________ <br />
          ______________________ <br />
          ______________________ <br />
          远方有琴 愀然空灵 声声催天雨<br />
          涓涓心事说给自己听<br />
          月影憧憧 烟火几重 烛花红<br />
          红尘旧梦 梦断都成空<br />
          雨打湿了眼眶 年年倚井盼归堂<br />
          最怕不觉泪已拆两行<br />
          我在人间彷徨 寻不到你的天堂<br />
          东瓶西镜放 恨不能遗忘<br />
          又是清明雨上 折菊寄到你身旁<br />
          把你最爱的歌来轻轻唱<br />
          我在人间彷徨 寻不到你的天堂<br />
          东瓶西镜放 恨不能遗忘<br />
          又是清明雨上 折菊寄到你身旁<br />
          把你最爱的歌来轻轻唱<br />
        </p>
      </div>
    </div>
    <audio src="./清明雨上-许嵩.mp3" id="audio" controls autoplay></audio>
    <script>
      window.onload = function () {
        var audio = document.querySelector("#audio");
        // audio.currentTime = 0;
      };

      var pObj = document.querySelector("p");
      var move = setInterval(function () {
        var top1 = parseInt(getComputedStyle(pObj, false)["margin-top"]);
        pObj.style.marginTop = --top1 + "px";
        if (top1 == -800) {
          setInterval(scroll);
        }
      }, 150);

      var move = document.querySelector(".move");
      move.onclick = function () {
        var audio = document.getElementById("audio");
        if (audio.paused) {
          audio.play();
          document.getElementById("stop1").style.animationPlayState = "running";
        } else {
          audio.pause();
          document.getElementById("stop1").style.animationPlayState = "paused";
        }
      };

      // var flag = true; //用作标志

      // function run() {
      //   if (flag == true) {
      //     $(".move").css("animation-play-state", "paused"); //设置动画状态--暂停
      //     flag = false;
      //     // console.log(flag);
      //   } else {
      //     $(".move").css("animation-play-state", "running"); //设置动画状态--开始
      //     flag = true;
      //     // console.log(xx);
      //   }
      // }
      //   控件！
      var audio;
      window.onload = function () {
        initAudio();
      };
      var initAudio = function () {
        //audio =  document.createElement("audio")
        //audio.src='Never Say Good Bye.ogg'
        audio = document.getElementById("audio");
      };
      function change() {
        audio.currentTime = 30;
      }
      function getCurrentTime(id) {
        alert(parseInt(audio.currentTime) + "：秒");
      }

      function playOrPaused(id, obj) {
        if (audio.paused) {
          audio.play();
          obj.innerHTML = "暂停";
          return;
        }
        audio.pause();
        obj.innerHTML = "播放";
      }

      function hideOrShowControls(id, obj) {
        if (audio.controls) {
          audio.removeAttribute("controls");
          obj.innerHTML = "显示控制框";
          return;
        }
        audio.controls = "controls";
        obj.innerHTML = "隐藏控制框";
        return;
      }
      function vol(id, type, obj) {
        if (type == "up") {
          var volume = audio.volume + 0.1;
          if (volume >= 1) {
            volume = 1;
          }
          audio.volume = volume;
        } else if (type == "down") {
          var volume = audio.volume - 0.1;
          if (volume <= 0) {
            volume = 0;
          }
          audio.volume = volume;
        }
        document.getElementById("nowVol").innerHTML = returnFloat1(
          audio.volume
        );
      }
      function muted(id, obj) {
        if (audio.muted) {
          audio.muted = false;
          obj.innerHTML = "开启静音";
        } else {
          audio.muted = true;
          obj.innerHTML = "关闭静音";
        }
      }
      //保留一位小数点

      function returnFloat1(value) {
        value = Math.round(parseFloat(value) * 10) / 10;
        if (value.toString().indexOf(".") < 0) {
          value = value.toString() + ".0";
        }
        return value;
      }
    </script>
  </body>
</html>
